package com.hengda.smart.speak.d.util;

import android.content.Context;
import android.content.SharedPreferences;


public class SharePreferenceUtil {

	private SharedPreferences sp;
	private SharedPreferences.Editor editor;

	public SharePreferenceUtil(Context context, String file) {
		sp = context.getSharedPreferences(file, Context.MODE_PRIVATE);
		editor = sp.edit();
	}
	//=================================================================================

	//=================================================================================
	public void setLocalLanguage(String language) {
		editor.putString("DeviceLanguage", language);
		editor.commit();
	}

	public String getLocalLanguage() {
		return sp.getString("DeviceLanguage", "JAPANESE");
	}

	public void setLanguage(int flag) {
		editor.putInt("LANGUAGE_SELECT", flag);
		editor.commit();
	}

	public int getLanguage() {
		return sp.getInt("LANGUAGE_SELECT", 0);
	}

	//===========================十待机控制器专用===============================================

	// 用于控制器占用冲突回滚
	public void setLocalAutoNo(int areaNo) {
		editor.putInt("local_auto", areaNo);
		editor.commit();
	}

	// 用于控制器占用冲突回滚
	public int getLocalAutoNo() {
		return sp.getInt("local_auto", 1);
	}

	public void setLocalIRPlayNo(int areaNo) {
		editor.putInt("local_ir_play", areaNo);
		editor.commit();
	}

	public int getLocalIRPlayoNo() {
		return sp.getInt("local_ir_play", 0);
	}



	// 用于控制器占用冲突回滚
	public void setCacheHostNo(int cacheNo) {
		editor.putInt("cacheHostNo", cacheNo);
		editor.commit();
	}

	// 用于控制器占用冲突回滚
	public int getCacheHostNo() {
		return sp.getInt("cacheHostNo", 0);
	}

	public void setHostNo(int channel) {
		editor.putInt("ChannelNo", channel);
		editor.commit();
	}

	public int getHostNo() {
		return sp.getInt("ChannelNo", 0);
	}


	public void setChannelEditString(String channelS){
		editor.putString("ChannelString", channelS);
		editor.commit();
	}
	public String getChannelEditString(){
		return sp.getString("ChannelString", "0#0#0#0#0#0#0");
	}


	public void setChannel0No(int channel){
		editor.putInt("Channel800No0", channel);
		editor.commit();
	}

	public int getChannel0No(){
		return sp.getInt("Channel800No0",1);
	}
	public void setChannel1No(int channel){
		editor.putInt("Channel800No1", channel);
		editor.commit();
	}
	public int getChannel1No(){
		return sp.getInt("Channel800No1", 0);
	}
	public void setChannel2No(int channel){
		editor.putInt("Channel800No2", channel);
		editor.commit();
	}

	public int getChannel2No(){
		return sp.getInt("Channel800No2", 0);
	}
	public void setChannel3No(int channel){
		editor.putInt("Channel800No3", channel);
		editor.commit();
	}

	public int getChannel3No(){
		return sp.getInt("Channel800No3",0);
	}
	public void setChannel4No(int channel){
		editor.putInt("Channel800No4", channel);
		editor.commit();
	}

	public int getChannel4No(){
		return sp.getInt("Channel800No4",0);
	}
	public void setChannel5No(int channel){
		editor.putInt("Channel800No5", channel);
		editor.commit();
	}

	public int getChannel5No(){
		return sp.getInt("Channel800No5",0);
	}
	public void setChannel6No(int channel){
		editor.putInt("Channel800No6", channel);
		editor.commit();
	}

	public int getChannel6No(){
		return sp.getInt("Channel800No6",0);
	}
	public void setChannel7No(int channel){
		editor.putInt("Channel800No7", channel);
		editor.commit();
	}

	public int getChannel7No(){
		return sp.getInt("Channel800No7",0);
	}

	public void setChannelInterval(long time) {
		editor.putLong("ChannelInterval", time);
		editor.commit();
	}

	public long getChannelInterval() {
		return sp.getLong("ChannelInterval", 3000);
	}

	public void setChannelVolume(int volume) {
		editor.putInt("ChannelVolume", volume);
		editor.commit();
	}

	public int getChannelVolume() {
		return sp.getInt("ChannelVolume", 31);
	}

	public void setDeviceId(int id) {
		editor.putInt("DeviceID", id);
		editor.commit();
	}

	public int getDeviceId() {
		return sp.getInt("DeviceID", 9);
	}

	public void setChannelNo(int id) {
		editor.putInt("channel", id);
		editor.commit();
	}

	public int getChannelNo() {
		return sp.getInt("channel", 0);
	}

	/***设置800M功率***/
	public void set800MPower(int power){
		editor.putInt("POWER_800M", power);
		editor.commit();
	}
	/***获取800M功率***/
	public int get800MPower(){
		return sp.getInt("POWER_800M", 4);
	}
	/***设置数传功率***/
	public void setShuChuanPower(int power){
		editor.putInt("POWER_SC", power);
		editor.commit();
	}
	/***获取数传功率***/
	public int getShuChuanPower(){
		return sp.getInt("POWER_SC", 5);
	}


	//=======================DDPUSH推送专用================================
//     uuid       UUID
//     serverAddr,  服务器地址
//     int serverPort, 服务器端口号
	public void setDDUuid(String UUID) {
		editor.putString("DD_UUID", UUID);
		editor.commit();
	}
	public String getDDUuid(){
		return sp.getString("DD_UUID", "");
	}

	public void setDDServerIP(String ip ){
		editor.putString("DD_SERVER_IP", ip);
		editor.commit();
	}

	public String getDDServerIP(){
		return sp.getString("DD_SERVER_IP", "192.168.10.248");
	}


	public void setDDPort(int port){
		editor.putInt("DD_PORT", port);
		editor.commit();
	}

	public int getDDPort(){
		return sp.getInt("DD_PORT", 9966);
	}

	public void setPHPServerIP(String ip ){
		editor.putString("PHP_Server_IP", ip);
		editor.commit();
	}

	public String getPHPServerIP(){
		return sp.getString("PHP_Server_IP", "192.168.10.248");
	}


	public void setPHPPort(int port){
		editor.putInt("PHPPort", port);
		editor.commit();
	}

	public int getPHPPort(){
		return sp.getInt("PHPPort", 80);
	}
	//=======================开关配置信息============================


	//=======================开关配置信息============================
	//mic讲解打开
	public void setSwitchMic(Boolean state){
		editor.putBoolean("SWITCH_MIC", state);
		editor.commit();
	}

	public Boolean getSwitchMic(){
		return sp.getBoolean("SWITCH_MIC",true);
	}

	//辅助定位开关
	public void setSwitchLocation(Boolean state){
		editor.putBoolean("SWITCH_LOCAT", state);
		editor.commit();
	}

	public Boolean getSwitchLocation(){
		return sp.getBoolean("SWITCH_LOCAT", true);
	}

	//记录用户登录状态
	public void setLoginState(Boolean loginState){
		editor.putBoolean("LOGIN_STATE", loginState);
		editor.commit();
	}

	public Boolean getLoginState(){
		return sp.getBoolean("LOGIN_STATE", false);
	}
	//登录多选框选中未选中的状态
	public void setloginRember (boolean remember){
		editor.putBoolean("LOGIN_REM", remember);
		editor.commit();
	}

	public Boolean getLoginRember(){
		return sp.getBoolean("LOGIN_REM", false);
	}

	//十代机通信状态
	//=======================WEBSERVICE 接口专用==========================
	public void  setToken(String token){
		editor.putString("WEB_TOKEN", token);
		editor.commit();
	}
	public String getToken(){
		return sp.getString("WEB_TOKEN", "");
	}
	public void  setLoginToken(String token){
		editor.putString("WEB_LOG_TOKEN", token);
		editor.commit();
	}
	public String getLoginToken(){
		return sp.getString("WEB_LOG_TOKEN", "");
	}

	public void setCurrentTaskId(String taskID){
		editor.putString("TASK_ID", taskID);
		editor.commit();
	}

	public String getCurrentTaskId(){
		return sp.getString("TASK_ID", "");
	}

	//记住密码
	public void setLoginPwd(String pwd){
		editor.putString("PWD", pwd);
		editor.commit();
	}
	public String getLoginPwd(){
		return sp.getString("PWD", "");
	}
	public void setLoginUid(String uid){
		editor.putString("Uid", uid);
		editor.commit();
	}
	public String getLoginUid(){
		return sp.getString("Uid", "");
	}
//======================================================================
//====================updata20150924 增加EQ音质设置=========================
//======================================================================
//======================================================================

	public void setEQ1(int EQ1){
		editor.putInt("EQ1", EQ1);
		editor.commit();
	}

	public int getEQ1(){
		return sp.getInt("EQ1",8);
	}
	public void setEQ2(int EQ2){
		editor.putInt("EQ2", EQ2);
		editor.commit();
	}

	public int getEQ2(){
		return sp.getInt("EQ2",8);
	}
	public void setEQ3(int EQ3){
		editor.putInt("EQ3", EQ3);
		editor.commit();
	}

	public int getEQ3(){
		return sp.getInt("EQ3",8);
	}
	public void setEQ4(int EQ4){
		editor.putInt("EQ4", EQ4);
		editor.commit();
	}

	public int getEQ4(){
		return sp.getInt("EQ4",8);
	}

	public int getEQ5(){
		return sp.getInt("EQ5",8);
	}

	public void setEQ5(int EQ5){
		editor.putInt("EQ5", EQ5);
		editor.commit();
	}
	//=================上传位置信息===========================
	public void setLocalAuto(String localAutoNo){
		editor.putString("local_no",localAutoNo );
		editor.commit();
	}

	public String getLocalAuto(){
		return sp.getString("local_no", "0");
	}
	//=================check======================
	public void setCheck(int num){
		editor.putInt("check",num );
		editor.commit();
	}

	public int getCheck(){
		return sp.getInt("check", 0);
	}

}




